package network;

import java.io.IOException;
import java.util.HashMap;

public class TcpDictServer extends TcpThreadEchoServer{
    private HashMap<String,String> dict = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("pig","猪");
    }

    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该单词未被记录在翻译册");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }
}
